package com.noble.meether.ui.certify;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.noble.glamour.module.logic.application.ModuleMgr;
import com.noble.glamour.module.logic.baseui.LoadingDialog;
import com.noble.glamour.module.logic.request.HttpResponse;
import com.noble.glamour.module.logic.request.RequestComplete;
import com.noble.library.base.BaseAppCompatActivity;
import com.noble.library.camera.ImgSelectUtil;
import com.noble.library.image.ImageLoader;
import com.noble.meether.R;

/**
 * 女性： 性别认证
 */
public class SexAuthAct extends BaseAppCompatActivity implements View.OnClickListener, RequestComplete, ImgSelectUtil.OnChooseCompleteListener {
    private ImageView img_action;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.act_sex_auth);
        initView();
    }

    private void initView() {
        setBackView("性别认证");
        img_action = findViewById(R.id.img_action);
        findViewById(R.id.btn_take).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_take:
                ImgSelectUtil.getInstance().takePhoto(this, this);
                break;
        }
    }

    @Override
    public void onRequestComplete(HttpResponse response) {
        if (response.isOk()) {
            finish();
        }
    }

    @Override
    public void onUrl(String url) {
        LoadingDialog.show(this, "正在上传...");
        if (img_action != null)
            ImageLoader.loadRoundCenterCrop(this, url, img_action);
        ModuleMgr.getCenterMgr().uploadSexAuth(this, url, this::onRequestComplete);
    }
}
